package org.nicocube.airain.gwt.client.ui.canvas;

import com.google.gwt.widgetideas.graphics.client.Color;
import com.google.gwt.widgetideas.graphics.client.GWTCanvas;

public class ScheduleCanvasPainter {

	protected GWTCanvas canvas;
	private int r;
	private int g;
	private int b;
	private int a;
	private int colorindex;

	public ScheduleCanvasPainter(GWTCanvas canvas) {
		this.canvas = canvas;
		r = 80;
		g = 80;
		b = 80;
		a = 100;
	}

	public void draw() {
		double x = 70;
		double y = 40;
		canvas.setFillStyle(this.getColor());
		canvas.beginPath();
		canvas.moveTo(x,y); //(75,40);
		canvas.cubicCurveTo(x,y-3,x-5,y-15,x-20,y-15);//(75,37,70,25,50,25);
		canvas.cubicCurveTo(x-55,y-15,x-55,y+12.5,x-55,y+12.5);//(20,25,20,62.5,20,62.5);
		canvas.cubicCurveTo(x-55,y+40,x-35,y+62,x,y+80);//(20,80,40,102,75,120);
		canvas.cubicCurveTo(x+35,y+62,x+55,y+40,x+55,y+12.5);//(110,102,130,80,130,62.5);
		canvas.cubicCurveTo(x+55,y+12.5,x+55,y-15,x+25,y-15);//(130,62.5,130,25,100,25);
		canvas.cubicCurveTo(x+10,y-15,x,y-3,x,y);//(85,25,75,37,75,40);
		canvas.fill();
		this.colorShift();
	}

	private void colorShift() {
		colorindex ++;
		r = (120+r+colorindex*50)%255;
		g = (120+g+colorindex*150)%255;
		b = (120+b+colorindex*250)%255;
	}

	private Color getColor() {
		return new Color(r,g,b,a);
	}

}
